package br.com.async.infrastructure.impl;

import org.hibernate.Criteria;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;

import br.com.async.domain.login.LoginRepository;
import br.com.async.domain.login.User;
import br.com.async.infrastructure.AbstractRepositoryImpl;

public class LoginRepositoryImpl extends AbstractRepositoryImpl<User, Integer> implements LoginRepository{

	public LoginRepositoryImpl() {
		super(User.class);
	}

	@Override
	public User doLogin(String userName, String password) {
		Criteria criteria = getSession().createCriteria(entityClass);
		
		Criterion c1 = Restrictions.eq("password", password);
		criteria.add(c1);
		
		return (User) criteria.uniqueResult();
	}

	@Override
	public void doLogout(User user) {
		
	}

}
